$('document').ready(function(){
	loadLink();
});

function loadLink(){
	$('.loadlink').click(function(event){
		$('#content').load($(this).attr('href'));
		event.preventDefault();
	});	
}

var timeout	= 300;
var closetimer	= 0;
var ddmenuitem	= 0;

function mopen(id)
{	
	mcancelclosetime();

	if(ddmenuitem) ddmenuitem.style.display = 'none';
	
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.display = 'block';
}

function mclose()
{
	if(ddmenuitem) ddmenuitem.style.display = 'none';
}


function mclosetime()
{
	
	closetimer = window.setTimeout(mclose, timeout);
}

function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

document.onclick = mclose;  

function uploadQuote(){
	var first_name = document.getElementsByName('first_name')[0].value;
	var name = document.getElementsByName('name')[0].value;
	var quote = document.getElementsByName('quote')[0].value;
	
	var xmlhttp;
	
	try{
		// Opera 8.0+, Firefox, Safari, Chrome
		xmlhttp = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Error
				alert("Error");
				return false;
			}
		}
	}
	
	xmlhttp.onreadystatechange = function(){
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
			document.getElementById("content").innerHTML = xmlhttp.responseText;
		}
	}
	
	xmlhttp.open("POST","global.inc.php?fn=uploadQuote&param="+first_name+'|'
															  +name+'|'
															  +quote,true);
	xmlhttp.send();	
}

function loadPage(pagename){
	var xmlhttp;
	
	try{
		// Opera 8.0+, Firefox, Safari, Chrome
		xmlhttp = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Error
				alert("Error");
				return false;
			}
		}
	}
	
	xmlhttp.onreadystatechange = function(){
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
			document.getElementById("content").innerHTML = xmlhttp.responseText;
		}
	}
	
	xmlhttp.open("GET",pagename+".php",true);
	xmlhttp.send();
}